package com.sq.loginservice.service.impl;

import cn.dev33.satoken.secure.SaSecureUtil;
import com.sq.api.dto.SysUserDto;
import com.sq.common.exception.server.ServiceException;
import org.springframework.stereotype.Component;

/**
 * @Author Li sir
 * @Date 2024/9/29
 */
@Component
public class SysPasswordService {


    public void validate(SysUserDto user, String password){
        String pass = user.getPassword();
        String salt = user.getSalt();

        String originalPass = SaSecureUtil.aesDecrypt(salt, pass);
        System.out.println(originalPass);
        if (!originalPass.equals(password)){
            throw new ServiceException("密码不正确");
        }
    }


}
